package com.ruoyi.iot.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.iot.domain.IotRulesAction;
import com.ruoyi.iot.mapper.IotRulesActionMapper;
import com.ruoyi.iot.service.IIotRulesActionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 规则执行动作Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-28
 */
@Service
public class IotRulesActionServiceImpl implements IIotRulesActionService {
    @Autowired
    private IotRulesActionMapper iotRulesActionMapper;

    /**
     * 查询规则执行动作
     *
     * @param actionId 规则执行动作主键
     * @return 规则执行动作
     */
    @Override
    public IotRulesAction selectIotRulesActionByActionId(Long actionId) {
        return iotRulesActionMapper.selectIotRulesActionByActionId(actionId);
    }

    /**
     * 查询规则执行动作列表
     *
     * @param iotRulesAction 规则执行动作
     * @return 规则执行动作
     */
    @Override
    public List<IotRulesAction> selectIotRulesActionList(IotRulesAction iotRulesAction) {
        return iotRulesActionMapper.selectIotRulesActionList(iotRulesAction);
    }

    /**
     * 新增规则执行动作
     *
     * @param iotRulesAction 规则执行动作
     * @return 结果
     */
    @Override
    public int insertIotRulesAction(IotRulesAction iotRulesAction) {
        iotRulesAction.setCreateTime(DateUtils.getNowDate());
        return iotRulesActionMapper.insertIotRulesAction(iotRulesAction);
    }

    /**
     * 修改规则执行动作
     *
     * @param iotRulesAction 规则执行动作
     * @return 结果
     */
    @Override
    public int updateIotRulesAction(IotRulesAction iotRulesAction) {
        iotRulesAction.setUpdateTime(DateUtils.getNowDate());
        return iotRulesActionMapper.updateIotRulesAction(iotRulesAction);
    }

    /**
     * 批量删除规则执行动作
     *
     * @param actionIds 需要删除的规则执行动作主键
     * @return 结果
     */
    @Override
    public int deleteIotRulesActionByActionIds(Long[] actionIds) {
        return iotRulesActionMapper.deleteIotRulesActionByActionIds(actionIds);
    }

    /**
     * 删除规则执行动作信息
     *
     * @param actionId 规则执行动作主键
     * @return 结果
     */
    @Override
    public int deleteIotRulesActionByActionId(Long actionId) {
        return iotRulesActionMapper.deleteIotRulesActionByActionId(actionId);
    }
}
